package com.osdp.common.sercurity.service.impl;

import com.osdp.common.exception.PlatformException;
import com.osdp.common.sercurity.domain.Principal;
import com.osdp.common.sercurity.domain.SecurityUser;
import com.osdp.common.sercurity.service.ITokenIdentifyService;
import com.osdp.common.base.JWTInfo;
import com.osdp.common.util.TokenUtil;
import org.springframework.stereotype.Service;

@Service
public class TokenIdentifyServiceImpl implements ITokenIdentifyService {
    @Override
    public boolean verify(String token) {
        return false;
    }

    @Override
    public boolean refresh(String token) {
        return false;
    }

    @Override
    public Principal getPrincipal(String token) {
        JWTInfo info = TokenUtil.verify(token);
        if(info == null){
            throw new PlatformException("获取token账号信息失败");
        }
        return new SecurityUser(info.getUserId(),info.getUserName());
    }
}
